use Mojo::mysql;
use strict;

my $mysql = Mojo::mysql->strict_mode('mysql://dahama:xxxxxxxxxx@/vpninfo');

my $db = $mysql->db;

sub regist_account{
    my $username=shift;
    my $name=shift;
    my $sbu_id=shift;
    my $department=shift;
    my $password=shift;
    my $up_admin=shift;
    my $userrole=shift;
    my $adminrole=shift;
    $db->query('insert into admin_account (username,name,sbu_id,department,password,userrole,up_admin,enable,adminrole) values (?,?,?,?,?,?,?,1,?',$username,$name,$sbu_id,$department,$password,$userrole,$up_admin,$adminrole);
}

sub edit_account{
    my $username=shift;
    my $type=shift;
    my $value=shift;
    $db->query('update admin_account set ?=? where username=?',$type,$value,$username);
}

sub show_account_list(
    my $account_list = $db->query('select * from admin_account')->hashes;
    print $account_list->[0]->{username},"\n";
)